using System;
using UnityEngine;

// Plan to go to a position without using pathfinding
public class PlanGoToPosition : Plan
{

	private AgentBehaviourScript agent; 
	private float minDistanceToDestination;
	private Vector3 destination;
	
	public PlanGoToPosition(AgentBehaviourScript agent, Vector3 destination, float minDistanceToDestination)
	{
		this.agent = agent;
		this.destination = destination;
		this.minDistanceToDestination = minDistanceToDestination;
	}
	
	public override bool execute()
	{
		if (Vector3.Distance(agent.getPosition(), destination) < minDistanceToDestination)
		{
			//Plan finished
			return false;
		}else
		{
			agent.setDestination(destination);
			//The Plan continues
			return true;
		}
	}
	
	public override pathplanner getPathPlanner() {
		
		return null;

	}

	public override string ToString ()
	{
		return string.Format ("PlanGoToPosition(" + (int)destination.x + "," + (int)destination.y + "," + (int)destination.z + ")" );
	}	
	
}

